package com.guijq.design.singleton;

/**
 * @author yangjf
 * @version 0.1.0
 * @time 2018/9/12/012
 */
public class Singleton {
    private static Singleton uniqueInstance;

    private Singleton() {
    }

    /**
     *
     * @return
     *
     * synchronized 保证了线程安全，但是后续调用getInstance时，影响了性能
     */
    public static synchronized Singleton getInstance() {
        if (uniqueInstance == null) {
            uniqueInstance = new Singleton();
        }
        return uniqueInstance;
    }
}
